package pl.edu.agh.mobicentsVoIP.core;

import java.util.HashSet;
import java.util.Set;

public class User{
	private String name;
	private String password;
	private String userURI;
	private Set<String> roles;
	public String getUserURI() {
		return userURI;
	}
	public void setUserURI(String userURI) {
		this.userURI = userURI;
	}
	private boolean registered;
	
	//Hibernate-purpose constructor
	public User(){}
	
	public User(String userURI){
		this.userURI = userURI;
		registered = true;
		name = userURI.split("@")[0].split(":")[1];
		password = "test";
	}
	
	public User(String name, String password, String userURI, boolean isAdmin){
		this.name = name;
		this.password = password;
		this.userURI = userURI;
		this.registered = true;
		this.roles = new HashSet<String>();
		roles.add("MobicentsUser");
		if(isAdmin)
			roles.add("MobicentsAdmin");
	}
	
	public boolean isRegistered() {
		return registered;
	}
	public void setRegistered(boolean registered) {
		this.registered = registered;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@Override
	public String toString(){
		return "[USER]: " + name + " | " + userURI;
	}
	public boolean getIsAdmin() {
		return roles.contains("MobicentsAdmin");
	}

	public void setRoles(Set<String> roles) {
		this.roles = roles;
	}
	public Set<String> getRoles() {
		return roles;
	}

}
